package cn.chencaiju.algorithm;

public class ContainsDuplicate {
	public static void main(String[] args) {
		int[] nums= {1,1,1,3,3,4,3,2,4,2};
		System.out.println(containsDuplicate(nums));
	}
	public static boolean containsDuplicate(int[] nums) {
		int end=nums.length;
		for(int i=0;i<end-1;i++) {
			for(int j=i+1;j<end;j++) {
				if(nums[i]==nums[j])
					return true;
			}
		}
		return false;
	}
	public static boolean containsNearbyDuplicate(int[] nums,int k) {
		int end=nums.length;
		for(int i=0;i<end-1;i++) {
			for(int j=i+1;j<end;j++) {
				if(nums[i]==nums[j]&&Math.abs(i-j)==k) {
					return true;
				}
			}
		}
		return false;
	}
}
